<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<view class="nav-header">
			<view class="nav-bar">
				<view class="nav-left" @click="goBack">
					<view class="back-arrow"></view>
				</view>
				<view class="nav-title">消息</view>
				<view class="nav-right"></view>
			</view>

			<!-- 占位区域（保持和 navigation.vue 一样的高度） -->
			<view class="search-placeholder"></view>
		</view>

		<!-- 消息列表卡片容器 -->
		<view class="message-view">
			<view class="message-card-container">
				<scroll-view class="message-list" scroll-y>
					<view class="message-item" v-for="(item, index) in messages" :key="index"
						@click="viewMessage(item)">
						<view class="message-header">
							<text class="message-title">{{ item.title }}</text>
							<text class="message-time">{{ item.time }}</text>
						</view>
						<text class="message-details">{{ item.details }}</text>
					</view>
				</scroll-view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';

	// 消息数据
	const messages = ref([{
			id: 1,
			title: '支付成功通知',
			details: '您已成功支付56.9元',
			time: '2023.3.11 11:09'
		},
		{
			id: 2,
			title: '支付成功通知',
			details: '您已成功支付56.9元',
			time: '2023.3.11 11:09'
		},
		{
			id: 3,
			title: '支付成功通知',
			details: '您已成功支付56.9元',
			time: '2023.3.11 11:09'
		},
		{
			id: 4,
			title: '支付成功通知',
			details: '您已成功支付56.9元',
			time: '2023.3.11 11:09'
		},
		{
			id: 5,
			title: '支付成功通知',
			details: '您已成功支付56.9元',
			time: '2023.3.11 11:09'
		},
		{
			id: 6,
			title: '支付成功通知',
			details: '您已成功支付56.9元',
			time: '2023.3.11 11:09'
		},
		{
			id: 7,
			title: '支付成功通知',
			details: '您已成功支付56.9元',
			time: '2023.3.11 11:09'
		},
		{
			id: 8,
			title: '支付成功通知',
			details: '您已成功支付56.9元',
			time: '2023.3.11 11:09'
		},
		{
			id: 9,
			title: '支付成功通知',
			details: '您已成功支付56.9元',
			time: '2023.3.11 11:09'
		}
	]);

	// 返回
	const goBack = () => {
		uni.navigateBack();
	};

	// 处理菜单点击
	const handleMenu = () => {
		// 菜单功能
	};

	// 处理更多点击
	const handleMore = () => {
		// 更多功能
	};

	// 查看消息详情
	const viewMessage = (item) => {
		// 查看消息详情
	};
</script>

<style scoped>
	.container {
		width: 100%;
		height: 100vh;
		display: flex;
		flex-direction: column;
		background: #f5f5f5;
		overflow: hidden;
	}

	/* 顶部导航栏 */
	.nav-header {
		background: linear-gradient(180deg, #2477F4 0%, #166BEC 100%);
		padding-top: 30rpx;
		padding-bottom: 30rpx;
	}

	.nav-bar {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 30rpx;
		padding-top: calc(20rpx + env(safe-area-inset-top));
		position: relative;
	}

	.nav-left {
		width: 80rpx;
		display: flex;
		align-items: center;
		cursor: pointer;
	}

	.back-arrow {
		width: 24rpx;
		height: 24rpx;
		border-left: 4rpx solid #fff;
		border-bottom: 4rpx solid #fff;
		transform: rotate(45deg);
		margin-left: 10rpx;
	}

	.nav-title {
		flex: 1;
		text-align: center;
		font-size: 36rpx;
		font-weight: 500;
		color: #fff;
		position: absolute;
		left: 0;
		right: 0;
		pointer-events: none;
	}

	.nav-right {
		width: 80rpx;
	}

	.icon-circle {
		width: 56rpx;
		height: 56rpx;
		border-radius: 50%;
		background: rgba(255, 255, 255, 0.25);
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.three-dots {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 4rpx;
	}

	.dot {
		width: 5rpx;
		height: 5rpx;
		background: #fff;
		border-radius: 50%;
	}

	.target-icon {
		position: relative;
		width: 28rpx;
		height: 28rpx;
	}

	.outer-circle {
		position: absolute;
		top: 0;
		left: 0;
		width: 28rpx;
		height: 28rpx;
		border: 2rpx solid #fff;
		border-radius: 50%;
	}

	.inner-circle {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: 10rpx;
		height: 10rpx;
		background: #fff;
		border-radius: 50%;
	}

	/* 搜索栏占位（保持和 navigation.vue 一样的高度） */
	.search-placeholder {
		height: 250rpx;
	}

	/* 消息视图 */
	.message-view {
		flex: 1;
		padding: 0 30rpx 20rpx 30rpx;
		margin-top: -250rpx;
		height: 0;
		overflow: visible;
		display: flex;
		flex-direction: column;
	}

	/* 消息卡片容器 - 和 navigation.vue 的卡片样式一样，高度自适应 */
	.message-card-container {
		width: 100%;
		background: #fff;
		border-radius: 20rpx;
		overflow: hidden;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
		padding: 20rpx;
		box-sizing: border-box;
		align-self: flex-start;
		display: flex;
		flex-direction: column;
		max-height: calc(100vh - 350rpx);
	}

	/* 消息列表 - 自适应高度，超出时可滚动 */
	.message-list {
		width: 100%;
		flex: 1;
		height: 0;
	}

	/* 消息卡片 - 无背景色，只有分隔线 */
	.message-item {
		padding: 30rpx;
		border-bottom: 1rpx solid #E5E5E5;
		width: 100%;
		box-sizing: border-box;
	}

	.message-item:last-child {
		border-bottom: none;
	}

	/* 消息头部 - 标题和时间在同一行 */
	.message-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 12rpx;
		width: 100%;
	}

	/* 消息标题 - 黑色，标准无衬线，中等粗细 */
	.message-title {
		font-size: 32rpx;
		font-weight: 500;
		color: #000;
		flex: 1;
		line-height: 1.4;
	}

	/* 时间戳 - 浅灰色，与详情相同大小，右对齐 */
	.message-time {
		font-size: 28rpx;
		color: #999;
		margin-left: 20rpx;
		flex-shrink: 0;
		white-space: nowrap;
	}

	/* 消息详情 - 浅灰色，比标题小 */
	.message-details {
		font-size: 28rpx;
		color: #999;
		line-height: 1.5;
		display: block;
	}
</style>